const server = require('server')

const {
  header
} = server.reply

module.exports = [
  ctx => header("Access-Control-Allow-Origin", ctx.headers.origin || "*"),
  ctx => header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"),
  ctx => header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"),
  ctx => ctx.method.toLowerCase() === 'options' ? 200 : false
]
